﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using TicketSeller;

namespace FlightSearchServer
{
    [Serializable]
    [DataContract]
    class Route
    {

        public Route(Ticket firstLeg)
        {
            Type = RouteType.Direct;
            FirstLegDate = firstLeg.date;
            FirstLegFlightNo = firstLeg.flightNo;
            FirstLegFrom = firstLeg.source;
            FirstLegTo = firstLeg.destination;
            FirstLegAirCarrier = firstLeg.airCarrier;
            alliance = firstLeg.alliance;
        }

        public Route(Ticket firstLeg, Ticket secondLeg)
        {
            Type = RouteType.InDirect;

            FirstLegDate = firstLeg.date;
            FirstLegFlightNo = firstLeg.flightNo;
            FirstLegFrom = firstLeg.source;
            FirstLegTo = firstLeg.destination;
            FirstLegAirCarrier = firstLeg.airCarrier;
            alliance = firstLeg.alliance;

            SecondLegDate = secondLeg.date;
            SecondLegFlightNo = secondLeg.flightNo;
            SecondLegFrom = secondLeg.source;
            SecondLegTo = secondLeg.destination;
            SecondLegAirCarrier = secondLeg.airCarrier;
        }

        [DataMember]
        public RouteType Type
        {
            set;
            get;
        }

        [DataMember]
        public string FirstLegFrom { set; get; }

        [DataMember]
        public string FirstLegTo { set; get; }

        [DataMember]
        public string FirstLegDate { set; get; }

        [DataMember]
        public string SecondLegFrom { set; get; }

        [DataMember]
        public string SecondLegTo { set; get; }

        [DataMember]
        public string SecondLegDate { set; get; }

        [DataMember]
        public string FirstLegFlightNo { set; get; }

        [DataMember]
        public string SecondLegFlightNo { set; get; }

        [DataMember]
        public string FirstLegAirCarrier { set; get; }

        [DataMember]
        public string SecondLegAirCarrier { set; get; }

        [DataMember]
        public string alliance { set; get; }
    }

    [Serializable]
    enum RouteType
    {
        Direct, InDirect
    }
}
